<template>
	<view id="wrap">
		<view class="headImg">
			<c-navBar title="提现" isPerch isTran></c-navBar>

			<view class="head_content">
				可提现积分：{{num}}
			</view>
		</view>
		<view class="main">
			<view class="main_title">
				提现积分
			</view>
			<view class="main_input">
				<input type="digit" v-model="number" placeholder="0"/>
			</view>
			<view class="main_infuse">
				输入你需要提现的积分提交提现申请
			</view>
			<view class="btn" @click="withdrawal">
				确定
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				num: 0, //可提现数量
				number: null, //提现数量
			}
		},
		methods: {
			// 提现
			withdrawal() {
				if (this.number > this.num) {
					uni.showToast({
						title: "积分不足",
						duration: 1000,
						icon: "error"
					})
					return
				}
				
				if (!this.number||this.number == 0) {
					uni.showToast({
						title: "请输入提现积分",
						duration: 1000,
						icon: "error"
					})
					return
				}

				this.$api.addWithdrawalLog({
					rattan: this.number
				}).then(res => {
					if (res.code == 200 && this.number > 0) {
						uni.showToast({
							title: "提现成功",
							icon: "success",
							duration: 1000
						})
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					} else {
						uni.showToast({
							title: "提现失败",
							icon: "error",
							duration: 1000
						})
						// setTimeout(()=>{
						// 	uni.navigateBack()
						// },1000)

					}

					console.log(res, "积分提现");
				})
			}

		},
		onLoad(options) {
			this.num = options.num
			console.log(options.num, "提现数量");

		}
	}
</script>

<style lang="scss" scoped>
	#wrap {
		.headImg {
			width: 750rpx;
			height: 320rpx;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			opacity: 1;


			.head_content {
				margin: 0rpx 32rpx;
				padding: 32rpx 0rpx;
				box-sizing: border-box;
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				color: #009E42;
				border-bottom: 1rpx #E5E5E5 solid;
			}
		}

		.main {
			padding: 0rpx 32rpx;
			box-sizing: border-box;

			.main_title {
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #1A1A1A;
			}

			.main_input {
				border-bottom: 1rpx solid #E5E5E5;
				font-size: 48rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				color: #1A1A1A;
				padding: 20rpx 0rpx;
				margin-top: 20rpx;
				height: 60rpx;
				
				input{
					height: 60rpx;
				}
			}

			.main_infuse {
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #999999;
				margin: 24rpx 0rpx 150rpx;
			}

			.btn {
				width: 686rpx;
				height: 96rpx;
				background: linear-gradient(135deg, #2AD03D 0%, #00B815 100%);
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				opacity: 1;
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
				line-height: 96rpx;
				text-align: center;
			}
		}
	}
</style>